<%@ page contentType="text/html;charset=UTF-8" language="java" %>  
<!DOCTYPE html>  
<html>  
<head>  
    <title>餐厅点餐管理</title>  
    <!-- 引入CSS和JS文件（如果需要） -->  
</head>  
<body>  



<div class="container"> 

<h2>所有菜品名称价格</h2> 
<a href="edit.jsp">增加菜品</a>
<table width="100%" border="1">
<tr>
            <th>ID</th>  
            <th>菜品名称</th>  
            <th>价格</th>  
        
<th width="10%">操作</th>
</tr>

    
<%

javax.sql.rowset.WebRowSet rs = com.myweb.DBTools.getRS("SELECT * FROM dishes");
while(rs.next()){
%>
<tr onclick="fillform(this)" style="cursor:pointer">
<td><%=rs.getString("dish_id")%></td>
<td><%=rs.getString("dish_name")%></td>
<td><%=rs.getString("price")%></td>
<td>
<a href="edit.jsp?dish_id=<%=rs.getString("dish_id")%>">修改</a>
<a href="save.jsp?btn=del&dish_id=<%=rs.getString("dish_id")%>" class="button-delete" onclick="return confirm('请确认是否删除当前记录？');">删除</a> 
</td>
</tr>
<%
}
rs.close();
%>
</table> 

<hr>
<form action="save.jsp" method="post">

<label for="dish_id">dish_id</label>
<input type="text" id="dish_id" name="dish_id" readonly><br>
<label for="dish_name">菜品名</label>
<input type="text" id="dish_name" name="dish_name" ><br>
<label for="price">价格</label>
<input type="text" id="price" name="price"><br>
<input type="submit" name="btn" value="修改">
<input type="submit" name="btn" value="新增"><br>

</form>

<script>
function fillform(row) {
    document.forms[0].dish_id.value = row.children[0].innerText;
    document.forms[0].dish_name.value = row.children[1].innerText;
    document.forms[0].price.value = row.children[2].innerText;
} 
</script>


</body>  
</html>